home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 3
/
Info_Mac_1994-01.iso
/
Development
/
Source
/
MSG Graphic Effects 1.0 Source
/
Random wipe.c
< prev
next >
Wrap
Text File
|
1993-08-21
|
2KB
|
66 lines
/*******************************************************************************
* Copywrite © 1992-1993 David S. Blumenthal *
* *
* This file is provided as is, and may be freely distributed unaltered. This *
* message must accompany any copy of this file. This file may be used or *
* modified for use for a non-commercial product provided that appropriate *
* credit is given to the author named above. *
* Commercial use of this source code is prohibited. *
******************************************************************************/
#include "msg misc.h"
#include "msg timing.h"
#define SUB_HOR 20
#define SUB_VER 20
#define AREA (SUB_HOR * SUB_VER)
#define CorrectTime 1
void RandomWipe(GrafPtr);
/* Basically, we divide the window into a bunch of blocks, and copy
each to the screen in random order. */
void RandomWipe(GrafPtr myGrafPtr)
{
int order[AREA];
int i;
long randtemp;
int ordertemp;
Rect subBox;
Rect dest;
Boolean everyOther;
everyOther=FALSE;
for(i = 0; i < AREA; i++)
order[i] = i;
for(i = (AREA - 1); i >= 0; i--) {
randtemp = ((((long)Random()) +32767) * (i + 1)) / 65535;
ordertemp = order[randtemp];
order[randtemp] = order[i];
order[i] = ordertemp;
}
for(i = 0; i < AREA; i++) {
StartTiming();
subBox.top = (((order[i] / SUB_VER) *
((myGrafPtr->portRect).bottom - (myGrafPtr->portRect).top))
/ SUB_VER) + (myGrafPtr->portRect).top;
subBox.left = (((order[i] % SUB_HOR) *
((myGrafPtr->portRect).right - (myGrafPtr->portRect).left))
/ SUB_HOR) + (myGrafPtr->portRect).left;
subBox.bottom = ((((order[i] / SUB_VER) + 1) *
((myGrafPtr->portRect).bottom - (myGrafPtr->portRect).top))
/ SUB_VER) + (myGrafPtr->portRect).top;
subBox.right = ((((order[i] % SUB_HOR) + 1) *
((myGrafPtr->portRect).right - (myGrafPtr->portRect).left))
/ SUB_HOR) + (myGrafPtr->portRect).left;
CopyBits(&(myGrafPtr->portBits), &(gMainWindow->portBits),
&subBox, &subBox, 0, 0L);
if (everyOther)
TimeCorrection(CorrectTime);
everyOther=!everyOther;
}
}